#ifndef CPP_ACTIVITY_MANAGER_H
#define CPP_ACTIVITY_MANAGER_H

#include <string>
#include <vector>

#include <Activity.h>

class Application;
class MainWindow;
class KeyEvent;

//@brief Activities Manager.
//@author cvte
class ActivityManager {
   public:
    typedef std::pair<std::string, Activity*> ActivityMap;
    typedef std::vector<ActivityMap> ActivityVector;

    static ActivityManager* getInstance();
    //@method 活动压栈，activityName为名字标识，activity为已创建的对象指针，如果为nullptr，那么会新建一个activity对象
    bool push(const std::string& activityName, Activity* activity);
    //@method 活动压栈，activityName为名字标识，会新建一个activity对象
    bool push(const std::string& activityName);
    Activity* pop();
    Activity* pop(Activity* activity);
    Activity* peek();
    Activity* peek(const std::string& activityName);
    void setVisibility(Activity* activity, int visibility);
    void sendNotify(int notifyId, void* data);
    void dispatchKeyEvent(KeyEvent& keyEvent);

    void setApplicationContext(Application* context);
    Application* getApplicationContext();

    void setWindow(MainWindow* window);
    MainWindow* getWindow();
    //打印Acitivty栈
    void printActivityStack();

   private:
    ActivityManager();
    virtual ~ActivityManager();

    //活动管理静态实例
    static ActivityManager* sInstance;
    ActivityVector mActivities;
    MainWindow* mWindow;
    Application* mContext;
};

#endif /* CPP_ACTIVITY_MANAGER_H */